#include "threadPool.h"

// 处理remove命令，即删除文件
int remove_work(client_info_t *client_info)
{
	// 先接收路径
	train_t train;
	memset(&train, 0, sizeof(train));
	recv(client_info->netfd, &train.len, sizeof(int), MSG_WAITALL);
	recv(client_info->netfd, train.data, train.len, MSG_WAITALL);

	strcat(client_info->global_path, train.data);

	if (remove(client_info->global_path) == 0)
	{
		printf("文件删除成功\n");
	}
	else
	{
		printf("文件删除失败\n");
	}

	for (int i = strlen(client_info->global_path) - 1; i > strlen(client_info->global_path) - train.len; i--)
	{
		client_info->global_path[i] = '\0';
	}
	strcat(client_info->global_path, "/");
	return 0;
}